package com.example.demo.entity;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Table(name = "tb_message", schema = "db_blog")
public class TbMessageEntity {
    private int messageId;
    private String messageContent;
    private Timestamp messageDatetime;
    private int messageUp;
    private String messageAuthor;

    @Id
    @Column(name = "message_id")
    public int getMessageId() {
        return messageId;
    }

    public void setMessageId(int messageId) {
        this.messageId = messageId;
    }

    @Basic
    @Column(name = "message_content")
    public String getMessageContent() {
        return messageContent;
    }

    public void setMessageContent(String messageContent) {
        this.messageContent = messageContent;
    }

    @Basic
    @Column(name = "message_datetime")
    public Timestamp getMessageDatetime() {
        return messageDatetime;
    }

    public void setMessageDatetime(Timestamp messageDatetime) {
        this.messageDatetime = messageDatetime;
    }

    @Basic
    @Column(name = "message_up")
    public int getMessageUp() {
        return messageUp;
    }

    public void setMessageUp(int messageUp) {
        this.messageUp = messageUp;
    }

    @Basic
    @Column(name = "message_author")
    public String getMessageAuthor() {
        return messageAuthor;
    }

    public void setMessageAuthor(String messageAuthor) {
        this.messageAuthor = messageAuthor;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TbMessageEntity that = (TbMessageEntity) o;
        return messageId == that.messageId &&
                messageUp == that.messageUp &&
                Objects.equals(messageContent, that.messageContent) &&
                Objects.equals(messageDatetime, that.messageDatetime) &&
                Objects.equals(messageAuthor, that.messageAuthor);
    }

    @Override
    public int hashCode() {
        return Objects.hash(messageId, messageContent, messageDatetime, messageUp, messageAuthor);
    }
}
